# 常量定义文件
# -*- coding: utf-8 -*-
"""项目配置常量模块
定义项目中使用的所有常量配置
"""

# ===============================================================================
# 业务领域：数据结构与字段定义
# ===============================================================================

# 字段名称常量
FIELD_NAMES = {
    "CUSTOMER_ABBREVIATION": "客户简称",
    "SPECIFICATION_MODEL": "规格型号",
    "QUANTITY": "数量",
    "ESTIMATED_COMPLETION_DATE": "预完工日期",
    "BOX_EXTERNAL_DIMENSIONS": "包装箱外口尺寸",
    "WEIGHT": "重量",
    "PACKAGING_SCHEME": "包装箱方案",
    "REMARKS": "备注",
}

# 必需字段列表（任务数据）
REQUIRED_FIELDS = [
    FIELD_NAMES["CUSTOMER_ABBREVIATION"],
    FIELD_NAMES["SPECIFICATION_MODEL"],
    FIELD_NAMES["QUANTITY"],
    FIELD_NAMES["ESTIMATED_COMPLETION_DATE"],
]

# 历史数据字段列表
HISTORICAL_FIELDS = [
    FIELD_NAMES["CUSTOMER_ABBREVIATION"],
    FIELD_NAMES["SPECIFICATION_MODEL"],
    FIELD_NAMES["QUANTITY"],
    FIELD_NAMES["ESTIMATED_COMPLETION_DATE"],
    FIELD_NAMES["BOX_EXTERNAL_DIMENSIONS"],
    FIELD_NAMES["WEIGHT"],
    FIELD_NAMES["PACKAGING_SCHEME"],
]

# ===============================================================================
# 业务领域：包装类型与分类
# ===============================================================================

# 包装类型常量
PACKAGE_TYPE = {
    "INDEPENDENT": "独立包装",
    "COMBINATION": "组合包装",
    "MIXED": "混合包装",
}

# 匹配结果标记常量
MATCH_STATUS = {
    "REUSE": "复用项",
    "REFERENCE": "参考项",
    "DESIGN": "设计项",
    "REFERENCE_INDEPENDENT": "参考项（仅独立包装）",
    "REFERENCE_COMBINATION": "参考项（仅组合包装）",
    "REFERENCE_MIXED": "参考项（混合包装）",
}

# 数据分类常量
CLASSIFICATION_CATEGORIES = {
    "REUSE": "复用项",
    "DESIGN": "设计项",
    "REFERENCE_INDEPENDENT": "参考项（仅独立包装）",
    "REFERENCE_COMBINATION": "参考项（仅组合包装）",
    "REFERENCE_MIXED": "参考项（混合包装）",
}

# ===============================================================================
# 业务领域：数据处理规则
# ===============================================================================

# 数据处理相关常量
DATA_VALIDATION_RULES = {
    "MIN_QUANTITY": 0,
    "MAX_QUANTITY": 1000000,
}

# 数据处理流程常量
PROCESSING_STAGES = {
    "IMPORT": "数据导入",
    "VALIDATION": "数据验证",
    "PREPROCESSING": "数据预处理",
    "MATCHING": "数据匹配",
    "RESULT_PROCESSING": "结果处理",
    "EXPORT": "数据导出",
}

# ===============================================================================
# 业务领域：匹配算法配置
# ===============================================================================

# 匹配算法配置
MATCHING_CONFIG = {
    "MIN_SIMILARITY_SCORE": 0.8,  # 最低相似度分数阈值
    "MAX_SEARCH_RESULTS": 10,  # 最大搜索结果数量
    "REUSE_THRESHOLD": 0.95,  # 复用项阈值
    "REFERENCE_THRESHOLD": 0.85,  # 参考项阈值
}

# 匹配阈值配置
MATCHING_THRESHOLDS = {
    "JACCARD_SIMILARITY": 0.7,
    "LEVENSHTEIN_SIMILARITY": 0.8,
    "COSINE_SIMILARITY": 0.75,
    "WEIGHTED_SIMILARITY": 0.8,
    "QUANTITY_MATCH": 0.9,
}

# 复用和参考阈值配置（为了兼容matcher.py中的导入）
REUSE_THRESHOLD = MATCHING_CONFIG["REUSE_THRESHOLD"]
REFERENCE_THRESHOLD = MATCHING_CONFIG["REFERENCE_THRESHOLD"]

# 迭代拆分常量
ITERATIVE_SPLITTING = {
    "MAX_ITERATIONS": 1000,  # 最大迭代次数
    "MIN_REMAINING_QUANTITY": 1,  # 最小剩余数量
    "MATCH_THRESHOLD_QUANTITY": 0.9,  # 数量匹配阈值
    "SIMILARITY_THRESHOLD": 0.95,  # 相似度阈值
    "MIN_ELIGIBLE_RECORDS": 2,  # 最小符合条件的记录数量
}

# ===============================================================================
# 业务领域：导出配置
# ===============================================================================

# 导出相关常量
EXPORT_SETTINGS = {
    "DEFAULT_SHEET_NAME": "包装方案查询结果",
    "HEADER_FORMAT": {
        "font": {
            "name": "微软雅黑",
            "size": 11,
            "bold": True,
            "color": "000000",
        },
        "alignment": {
            "horizontal": "center",
            "vertical": "center",
            "wrapText": True,
        },
        "fill": {
            "fill_type": "solid",
            "start_color": "DDEBF7",
        },
    },
}

# 文件格式常量
FILE_FORMATS = {
    "EXCEL": [".xlsx", ".xls"],
    "IMAGE": [".png", ".jpg", ".jpeg", ".gif"],
}

# 目录路径常量
OUTPUT_DIR = "output"
DEBUG_DIR = "debug"

# ===============================================================================
# 业务领域：用户界面配置
# ===============================================================================

# UI相关常量
UI_SETTINGS = {
    "DEFAULT_WINDOW_WIDTH": 1024,
    "DEFAULT_WINDOW_HEIGHT": 768,
    "THEME": "light",
}
